package com.qf.smsplatform.strategy.client;

import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.util.Map;
import java.util.Set;

/**
 * 缓存模块的feign接口
 * @author zjw
 */
@FeignClient(value = "sms-platform-cache")
public interface CacheClient {
    /**
     * 根据key和field查询hash结构中的value
     * @param key    redis的key
     * @param field  redis的hashKey
     * @return
     */
    @GetMapping("/cache/hget/{key}")
    String hget(@PathVariable String key,@RequestParam String field);


    /**
     * 根据key查询key-string结构中的数据
     * @param key
     * @return
     */
    @RequestMapping(value = "/cache/get-object/{key}", method = RequestMethod.GET)
    String getObject(@PathVariable("key") String key);

    /**
     * 根据key查询出全部的set集合中的信息
     * @param key
     * @return
     */
    @GetMapping("/cache/smembers/{key}")
    Set<Map> smembers(@PathVariable String key);

    /**
     * 扣除hash结构中某一个field的value
     * @param key
     * @param field
     * @param increment
     * @return
     */
    @PostMapping("/cache/hincr")
    Long hincr(@RequestParam String key,@RequestParam String field,@RequestParam long increment);
}
